<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/index.css" />
		<link rel="stylesheet" href="../../library/css/mui.picker.min.css" />
		<link rel="stylesheet" href="../css/page_3.css" />
		<link rel="stylesheet" href="../css/page_4.css" />
		<link rel="stylesheet" href="../../css/preimages.css" />
		<link rel="stylesheet" href="../../library/css/dialog.css" />
	</head>

	<body>
		<script src="../../js/mui.min.js"></script>
		<script type="text/javascript">
			mui.init();
		</script>
		<header class="mui-bar mui-bar-nav">
			<a id="back" href="javascript:void(0);" class="mui-icon mui-icon-left-nav mui-pull-left" style="color: #FFFFFF;"></a>
			<h1 class="mui-title"></h1>
			</header>
		<div class="mui-content">
			<div class="mui-card">
				<ul class="mui-table-view">
					<li class="mui-table-view-cell mui-media">
						<label>商机名称</label>
						<span id="sjmc">{{data.name}}</span>
					</li>
					<li class="mui-table-view-cell mui-media">
						<label>客户名称</label>
						<span id="khmc">{{data.CV_consumerName}}</span>
					</li>
					<li class="mui-table-view-cell mui-media">
						<label>拜访形式<i>&lt;选择&gt;</i></label>
						<span id="bfxs">{{data.CV_ways|bfxs}}</span>
					</li>
					<li class="mui-table-view-cell mui-media">
						<label>对方人员</label>
						<input type="text" placeholder="请输入对方名称" v-model="data.CV_oppositepeople" />
					</li>
					<li class="mui-table-view-cell mui-media">
						<label>拜访目的<i>&lt;选择&gt;</i></label>
						<span id="bfmd">{{data.CV_purpose|bfmd}}</span>
					</li>
					<li class="mui-table-view-cell mui-media">
						<label>客户反馈<i>&lt;选择&gt;</i></label>
						<span id="khfk">{{data.CV_feedback|khfk}}</span>
					</li>
					<li class="mui-table-view-cell mui-media">
						<label>图片附件</label>
						<div class="sel">
							<div id="show">点击查看
								<div class="imgs">
									<template v-for="item in data.CV_fileurl">
										<img src="{{item.Url}}" data-preview-src="" data-preview-group="1" />
									</template>
								</div>
							</div>
							<i id="down" style="color: #3A6C92;float: right;" v-gesture:tap.stop.prevent="down()">点击下载</i></div>
					</li>
				</ul>
			</div>
			<ul class="mui-card text-show mui-table-view">
				<li class="mui-table-view-cell-item text-title">
					交谈内容
				</li>
				<li class="mui-table-view-cell-item">
					<textarea class="text-txt" placeholder="请输入沟通内容" v-model="data.CV_talkdetails" style="width: 100%;">
						
					</textarea>
				</li>
			</ul>
			<ul class="mui-card text-show mui-table-view">
				<li class="mui-table-view-cell-item text-title">
					下步计划
				</li>
				<li class="mui-table-view-cell-item">
					<textarea class="text-txt" placeholder="请输入下部计划" v-model="data.CV_lowerplan" style="width: 100%;">
							
					</textarea>
				</li>
			</ul>
			<ul class="mui-card text-show mui-table-view">
				<li class="mui-table-view-cell-item text-title">
					备注
				</li>
				<li class="mui-table-view-cell-item">
					<textarea class="text-txt" placeholder="请输入派单人职责" v-model="data.CV_remark1" style="width: 100%;">
							
					</textarea>
				</li>
			</ul>
			<a href="javascript:void(0)" class="mui-card edit-btn" id="submit">
				提交信息
			</a>
		</div>
		<div id="dialog" style="display: none;">
			<div class="dialog">
				<div class="loging">
					<span class="mui-spinner"></span>
				</div>
				<div class="msg">
					下载中
				</div>
				<div class="btn">
					取消
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../js/evalHttp.js"></script>
	<script type="text/javascript" src="../../js/vue.js"></script>
	<script type="text/javascript" src="../../lease/js/vue-gesture.js"></script>
	<script type="text/javascript" src="../js/pageFilter.js"></script>
	<script type="text/javascript" src="../../library/js/mui.zoom.js"></script>
	<script type="text/javascript" src="../../library/js/mui.previewimage.js"></script>
	<script type="text/javascript" src="../../library/js/mui.picker.min.js"></script>
	<script type="text/javascript" src="../../js/file.js"></script>
	<script type="text/javascript" src="../../library/js/dialog.js"></script>
	<script>
		mui.previewImage();
		mui.plusReady(function() {
			var txtItems = mui(".text-txt");
			for(var i = 0; i < txtItems.length; i++) {
				txtItems[i].value = "";
			}
			Xeval.setUrl(Xeval.UrlModel.CRM);
			app.init();
		});
		var app = {
			datas: {
				pickers: {
					bfxs: new mui.PopPicker(),
					bfmd: new mui.PopPicker(),
					khfk: new mui.PopPicker()
				},
				options: {
					bfxs: [{
						text: "电话",
						value: "1"
					}, {
						text: "上门",
						value: "2"
					}],
					bfmd: [{
						text: "熟悉客户建立感情",
						value: "1"
					}, {
						text: "了解客户需求",
						value: "2"
					}, {
						text: "现场勘查诊断",
						value: "3"
					}, {
						text: "方案论证",
						value: "4"
					}, {
						text: "报价论证",
						value: "5"
					}, {
						text: "商定合同",
						value: "6"
					}, {
						text: "挖掘商机需求",
						value: "7"
					}, {
						text: "其他",
						value: "8"
					}],
					khfk: [{
						text: "认可",
						value: "1"
					}, {
						text: "观望",
						value: "2"
					}, {
						text: "冷漠",
						value: "3"
					}]
				},
				webData: {},
				vm: null,
				vmData: {}
			},
			methods: {
				sw: function() {
					var id = this.id;
					var that = this;
					app.datas.pickers.bfxs.blur;
					app.datas.pickers.bfmd.blur;
					app.datas.pickers.khfk.blur;
					switch(id) {
						case "sjmc":
							{
								mui.openWindow({
									url: "page_1.html",
									id: "page_1.html",
									extras: {
										backs: {
											back: true,
											id: "c_page_4_add.html"
										}
									}
								})
							};
							break;
						case "bfxs":
							{
								app.datas.pickers.bfxs.show(function(item) {
									app.datas.vmData.data.CV_ways = item[0].value;
								})
							};
							break;
						case "bfmd":
							{
								app.datas.pickers.bfmd.show(function(item) {
									app.datas.vmData.data.CV_purpose = item[0].value;
								})
							};
							break;
						case "khfk":
							{
								app.datas.pickers.khfk.show(function(item) {
									app.datas.vmData.data.CV_feedback = item[0].value;
								})
							};
							break;
						default:
							break;
					}
				},
				_SUBMIT: function() {
					var imgs = [];
					for(var i = 0; i < app.datas.vmData.data.CV_fileurl.length; i++) {
						imgs.push(app.datas.vmData.data.CV_fileurl[i].ID);
					}
					app.datas.vmData.data.CV_fileurl = imgs.join(",");
					Xeval.Http(Xeval.Mode.HTTP_ART_UPDATA_PF_BYIF, app.datas.vmData.data, app.methods._HTTP_CB_UPDATA)
				},
				down: function() {
					var files = app.datas.vmData.data.CV_fileurl;
					edialog.show();
					var len = files.length;
					var i = 0;
					down();

					function down() {
						evalFile.down(files[i].Url, files[i].Name, function(data, status) {
							if(status == 200 && data.totalSize == data.downloadedSize) {
								if(i < len) {
									down();
									i++;
								}
							}
						})
					}
					edialog.cancel();
					plus.nativeUI.confirm("下载成功,是否打开下载目录", function(e) {
						if(e.index == 0) {
							mui.openWindow({
								url: "../../download/download.html",
								id: "download.html"
							})
						} else {
							plus.nativeUI.toast("在首页我的信息中可以查看")
						}
					}, "下载完成", ["打开看看", "取消"]);
				},
				_HTTP_CB_UPDATA: function(isOk, data) {
					if(isOk) {
						if(data.state == 1) {
							mui.back();
						}
						plus.nativeUI.toast(data.msg);
					} else {
						plus.nativeUI.alert("网络错误，数据修改失败");
					}
				}
			},
			init: function() {
				document.getElementById("back").addEventListener("touchend", function() {
					//没道理啊！！！！
					edialog.back();
				})
				var web = plus.webview.currentWebview();
				app.datas.vmData.data = web.data;
				app.datas.vmData.data.CV_fileurl = app.datas.vmData.data.CV_fileurl.data;
				mui(".mui-title")[0].innerText = app.datas.vmData.data.name;
				app.datas.vm = new Vue({
					el: ".mui-content",
					data: app.datas.vmData,
					methods: app.methods
				});
				edialog.init("下载中,请稍等", function() {
					console.log(edialog.isShow())
					if(edialog.isShow()) {
						plus.nativeUI.confirm("文件下载中,是否取消下载?", function(e) {
							if(e.index == 0) {
								edialog.cancel();
								evalFile.clearDown();
							}
						}, "提示", ["确定", "取消"])
					} else {
						edialog.doms.back();
					}
				}, function() {
					edialog.back();
				});
				app.datas.pickers.bfxs.setData(app.datas.options.bfxs);
				app.datas.pickers.khfk.setData(app.datas.options.khfk);
				app.datas.pickers.bfmd.setData(app.datas.options.bfmd);
				mui(".mui-table-view-cell").on("tap", "span", app.methods.sw);
				document.getElementById("submit").addEventListener("touchend", app.methods._SUBMIT);
			}
		}
	</script>

</html>